from typing import List


class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:
        ans = ''
        if not strs or not len(strs[0]):
            return ans
        # print('123')
        # print(zip(*strs))
        # for x in zip(*strs):
        #     print(x)
        # print(map(set, zip(*strs)))
        # print('', list(map(set, zip(*strs))))
        for i in range(len(strs[0])):
            for j in range(1, len(strs)):
                if i >= len(strs[j]):
                    return ans
                if strs[j][i] != strs[0][i]:
                    return ans
            ans += strs[0][i]
        return ans


solve = Solution()
strs0 = ['flower', 'flow', 'flight']
print(strs0)
print('ans', f'[{solve.longestCommonPrefix(strs0)}]')


